package com.data.center.dictionary;

import com.data.center.exception.exception.BizException;
import com.data.center.exception.info.CommonEnum;

/**
 * @author DN
 * @description:学历编码映射枚举类CD000010
 * @date 2023/11/30 17：00
 */
public enum EducationLevel implements KeyValueMap {
    DOCTORAL_GRADUATE("11", "博士研究生"),
    MASTER_GRADUATE("14", "硕士研究生"),
    BACHELOR_UNDERGRADUATE("21", "大学本科"),
    COLLEGE_UNDERGRADUATE("31", "大学专科"),
    TECHNICAL_COLLEGE("41", "中等专科"),
    VOCATIONAL_HIGH_SCHOOL("44", "职业高中"),
    TECHNICAL_SCHOOL("47", "技工学校"),
    ORDINARY_HIGH_SCHOOL("60", "普通高中"),
    JUNIOR_HIGH_SCHOOL("70", "初级高中"),
    PRIMARY_SCHOOL("80", "小学"),
    OTHER("90", "其他");

    private String code;
    private String name;

    EducationLevel(String code, String name) {
        this.code = code;
        this.name = name;
    }

    @Override
    public String getKey() {
        return code;
    }

    @Override
    public String getValue() {
        return name;
    }

    public static EducationLevel getValueByKey(String key) {
        for (EducationLevel educationLevel : values()) {
            if (educationLevel.code.equals(key)) {
                return educationLevel;
            }
        }
        throw new BizException(CommonEnum.CAN_NOT_FIND_IN_DICTIONARY);
    }

    public static EducationLevel getKeyByValue(String value) {
        for (EducationLevel educationLevel : values()) {
            if (educationLevel.name.equals(value)) {
                return educationLevel;
            }
        }
        throw new BizException(CommonEnum.CAN_NOT_FIND_IN_DICTIONARY);
    }
}
